<template>
    <div class="mynews">
      <div class="title">
        <img src="../img/mynews/back.png" alt="" class="img1" @click="back">
        <span>我的消息</span>
        <img src="../img/myyinyue/yinp.png" alt="" class="img2">
      </div>
      <div class="news-nov">
        <ul>
          <li   ref="lis" v-for="(key,item) in text" @click="one(item)" :key="item">
            {{key}}
            <span>
             7
            </span>
          </li>

        </ul>
      </div>
      <div v-if="isShow===0">
        <sixin></sixin>
      </div>
      <div v-else-if="isShow===1">
        <pinlun></pinlun>
      </div>
      <div v-else-if="isShow===2">
        <aite></aite>
      </div>
      <div v-else>
        <tongzhi></tongzhi>
      </div>
    </div>
</template>

<script>
  import sixin from '../components/mynews/sixin';
  import tongzhi from '../components/mynews/tongzhi';
  import aite from '../components/mynews/aite';
  import pinlun from '../components/mynews/pinlun';
  import {mapState} from 'vuex';
    export default {
        components:{aite, sixin,tongzhi,pinlun},
        name: "mynews",
        data(){
          return{
            isShow:0,
            text:['私信','评论','@我','通知']
          }
        },
        computed:{
          ...mapState(['sixinTwo']),
       },
        methods:{
          back(){
            this.$router.go(-1);
          },
          one(key){
            this.isShow = key;
          },
        },

        watch:{
          isShow:function () {
            for(let i = 0; i < 4; i ++){
              if(this.isShow === i ){
              this.$refs.lis[i].style.color='white';
              this.$refs.lis[i].style.backgroundColor='#e15949';
            }else {
              this.$refs.lis[i].style.color='#e15949';
              this.$refs.lis[i].style.backgroundColor='white';
            }
          }
        }
      },
        mounted(){
        this.$refs.lis[0].style.color='white';
        this.$refs.lis[0].style.backgroundColor='#e15949';
        this.$refs.lis[1].children[0].style.display='none';
        this.$refs.lis[2].children[0].style.display='none';
        this.$refs.lis[3].children[0].style.display='none';

      },
      created(){
        this.$api.getSiXin({limit:30});
      },
    }
</script>

<style lang="scss">
*{
  margin: 0px;
  padding: 0px;
}
  .mynews{
    .title{
      box-sizing: border-box;
      background-color: #c64b3e;
      padding: 85px 0 30px 0;
      font-size: 50px;
      color: white;
      position: relative;
      text-align: center;
      font-weight: bold;
      img{
        width: 85px;
        position: absolute;
        vertical-align: middle;
      }
      .img1{
        left: 40px;
      }
      .img2{
        right: 50px;
      }
      span{
        display: inline-block;
        margin: 0 auto;
        vertical-align: middle;
      }
    }
    .news-nov{
      box-sizing: border-box;
      padding: 45px 30px;
      border-bottom: 1px solid #ccc;
      ul{
        width: 100%;
        height: 85px;
        border: 2.5px solid #e8c4c1;
        border-radius: 45px;
        font-size: 0;
        li{
          list-style: none;
          display: inline-block;
          height: 100%;
          border-radius: 45px;
          width: 25%;
          font-size: 38px;
          color: #d14f41;
          /*color: white;*/
          line-height: 85px;
          text-align: center;
          position: relative;
          /*background-color: #e15949;*/
          span{
            display: inline-block;
            box-sizing: border-box;
            font-size: 25px;
            color: white;
            font-weight: bold;
           width: 90px;
            text-align: center;
            position: absolute;
            line-height: 55px;
            border-radius: 27.5px;
            right: 0;
            background-color: #e15949;
            top: -20px;
          }

        }
        .li1{
          color: white;
          background-color: #e15949;
        }
      }
    }
  }
</style>
